package com.cenntro.common.redis;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 
 * @desc redis service
 */
public interface IRedisService {

	/**
	 * set redis 值
	 * @param key
	 * @param value
	 * @param expire
	 * @return
	 */
	public boolean set(final String key, final Object value, long... expire) ;
	/**
	 * redis取值
	 * @param key
	 * @return
	 */
	public  <T> T get(String key, Class<T> clazz);
	/**
	 * 设置过期
	 * @param key
	 * @param expire
	 * @return
	 */
	public boolean expire(String key, long expire);

//	public <T> boolean setList(String key, List<T> list);

//	public <T> List<T> getList(String key, Class<T> clz);

//	public long lpush(String key, Object obj);

//	public long rpush(String key, Object obj);

//	public String lpop(String key);
	/**
	 * 删除一个key
	 * @param key
	 */
	public void remove(String key);
	
	@Deprecated
	public <T> T getObject(final String key, Class<T> clazz);
	@Deprecated
	public Object getObject(final String key);
	@Deprecated
	public Boolean setObject(final String key, Object obj, final Long...ttl);
	@Deprecated
	public void setObject(final String key, byte[] obj, final Long...ttl);
	
	/**
	 * hash取值
	 * @param key
	 * @param field
	 * @return
	 */
	public <T> T hget(String key, String field);
	
	public <T> void hset(final String key, String field, T value);
	
	public <T> Map<String, T> hmget(String key);
	
	public <T> void hmset(final String key, Map<String, T> map);
	
	boolean tryLock(final String key);
	
	boolean setNX(final String key, final Object value);
	
	<T> T getSet(final String key, final T value);
	
	void sendMessage(String channel, String message);
	/*
	 * 列出通配符掩码keys
	 * wildcard 通配符掩码
	 */
	Set<String> keys(String wildcard);
	
	Long dbSize();
}